package com.buddha.api.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.buddha.api.entity.Role;
import com.buddha.api.mapper.RoleMapper;
import com.buddha.api.service.IRoleService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Lazy;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * <p>
 *  服务实现类
 * </p>
 *
 * @author mybatis-plus
 * @since 2023-07-06
 */
@Service
public class RoleServiceImpl extends ServiceImpl<RoleMapper, Role> implements IRoleService {

    @Lazy
    @Autowired
    RoleServiceImpl roleService;

    @Override
    public List<Role> findRoles(Integer id) {
        List<Role> userRoles = roleService.list(new QueryWrapper<Role>().inSql("id","select r_id from user_role where u_id = "+id));
        return userRoles;
    }
}
